package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserEcologyPoints;
import com.sc.nft.entity.vo.ecology.AdminQuotaLogVO;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserEcologyPointsQuotaLog;
import com.sc.nft.mapper.UserEcologyPointsQuotaLogMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * 用户生态燃料额度变动日志(user_ecology_points_quota_log)数据DAO
 *
 * @author Sun
 * @since 2023-11-23 11:22:41
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserEcologyPointsQuotaLogDao extends ServiceImpl<UserEcologyPointsQuotaLogMapper, UserEcologyPointsQuotaLog> {

    public Page<AdminQuotaLogVO> quotaLog(Page page, Long userId, String daoName,  String collectionName,Date startTime, Date endTime) {
        return baseMapper.quotaLog(page, userId, daoName,collectionName, startTime, endTime);
    }

    public UserEcologyPointsQuotaLog getLastOneByUserId(Long id) {
        LambdaQueryWrapper<UserEcologyPointsQuotaLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyPointsQuotaLog::getUserId, id);
        wrapper.orderByDesc(UserEcologyPointsQuotaLog::getId);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }
}